package com.zw.a.basic.a04.demo02_arry;

//案例: 演示数组的常见操作, 遍历数组.
//遍历数组: 意思是把数组中的每一个元素都打印到控制台上.
public class ArrayDemo02 {
    public static void main(String[] args) {
        //1.定义int类型的数组arr, 存储元素11, 22, 33, 44, 55.
        //int[] arr = new int[]{11, 22, 33, 44, 55};
        //语法糖
        int[] arr = {11, 22, 33, 44, 55};
        //2.通过for循环, 遍历数组.
        //方式一: 最Low版
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);
        System.out.println(arr[3]);
        System.out.println(arr[4]);
        System.out.println("-----------------------------");

        //方式二: for循环版
        for (int i = 0; i < arr.length; i++) {
            //System.out.println(i);            //打印索引
            System.out.println(arr[i]);         //根据索引找对应的元素.
        }
    }
}
